/**
 * @fileOverview
 * @author <a href="mailto:simonsliu@tencent.com">simonsliu</a>
 * @date 2012-03-24 18:02
 */
(function(window) {
    ClassManager = {
        /**
         * 创建命名空间
         * @param {String} sNamespace 命名空间字符串
         * @return {Object} 命名空间对象
         */
        namespace: function namespace(sNamespace) {
            var parts = sNamespace.split('.'), i, len, root = Cube.global, part;

            for (i = 0, len = parts.length; i < len; i++) {
                part = parts[i];
                if (!root[part]) {
                    root[part] = {};
                }
                root = root[part];
            }

            return root;
        },
	    /**
	     * 类继承方法
	     * @param {Cube.Base} subclass 子类
	     * @param {Cube.Base} superclass 父类
	     * @param {PlainObject} overrides 重载的方法与属性
	     */
	    extend: function extend(subclass, superclass, overrides) {
		    var Class = function(){};

		    Class.prototype = superclass.prototype;

		    subclass.prototype = new Class();
		    subclass.prototype.constructor = subclass;

		    if (overrides && Cube.isPlainObject(overrides)) {
			    Cube.merge(true, subclass.prototype, overrides);
		    }
	    },
	    /**
	     * 创建一个类
	     * @param {String} className 包含命名空间在内的类名
	     * @param {PlainObject} classData 类数据
	     * @param {Function} callback 类创建完成回调函数
	     */
	    define: function define(className, classData, callback) {
		    var namespace, realClassName,
			    Class = function(){
                    return this;
                };

		    namespace  = this.namespace(className.substr(0, className.lastIndexOf('.') - 1));
		    console.log('namespace', namespace);
		    realClassName = className.substr(className.lastIndexOf('.') + 1);
		    console.log('realClassName', realClassName);

		    namespace[realClassName] = Class;




	    }
    }
})(window);